#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
string s[N];
int ep[N];
int pcnt;
struct ACAM{
    int to[N][26];
    int fail[N];
    int id[N];
    int id1[N];
    int gen(){
        int now = ++pcnt;
        memset(to[now],0,sizeof(int)*26);
        fail[now] = 0;
        return now;
    }
    int rot;
    void init(){
        pcnt = 0;
        rot = gen();
    }
    int insert(string val,int idx){
        int now = rot;
        for(char c : val){   
            c -= 'a';
            if(!to[now][c]){
                to[now][c] = gen();
            }
            now = to[now][c];
        }
        id[now] = idx;
        return now;
    }
    vector<int> bian[N];
    int siz[N];
    int dfn[N];
    int dft;
    void dfs1(int x){
        dfn[x] = ++dft;
        siz[x] = 1;
        for(int v: bian[x]){
            dfs1(v);
            siz[x] += siz[v];
        }
    }
    void build(){
        queue<int> que;
        fail[rot] = rot;
        for(int i = 0;i < 26;i++){
            if(to[rot][i]){
                que.push(to[rot][i]);
                fail[to[rot][i]] = rot;
            }else{
                to[rot][i] = rot;
            }
        }
        while(que.size()){
            int now = que.front();
            que.pop();
            if(!id[now]){
                id[now] = id[fail[now]];
            }
            id1[now] = id[fail[now]];
            bian[fail[now]].push_back(now);
            for(int i = 0;i < 26;i++){
                if(to[now][i]){
                    que.push(to[now][i]);
                    fail[to[now][i]] = to[fail[now]][i];
                }else{
                    to[now][i] = to[fail[now]][i];
                }
            }
        }
        dfs1(1);
    }
    struct BIT{
        int tre[N];
        inline int lowbit(int x){
            return x & (-x);
        }
        void update(int p,int val){
            for(int i = p;i <= pcnt;i += lowbit(i)){
                tre[i] += val;
            }
        }
        int query(int p){
            int res = 0;
            for(int i = p;i >= 1;i -= lowbit(i)){
                res += tre[i];
            }
            return res;
        }
    }bit;
}acam;
bool cmp(const string &s1,const string &s2){
    return s1.size() > s2.size();
}
int main(){
    int n;
    cin>>n;
    for(int i = 1;i<=n;i++){
        cin>>s[i];
    }
    sort(s + 1,s + 1 + n,cmp);
    acam.init();
    for(int i = 1;i <= n;i++){
        ep[i] = acam.insert(s[i],i);
    }
    acam.build();
    int ans = 0;
    for(int i = 1;i <= n;i++){
        map<int,int> mp;
        vector<int> pos;
        int cur = acam.rot;
        for(int j = 0;j < s[i].size();j++){
            cur = acam.to[cur][s[i][j] - 'a'];
            acam.bit.update(acam.dfn[cur],1);
            pos.push_back(cur);   
        }
        int back = s[i].size();
        mp[acam.id1[pos[s[i].size() - 1]]]++;
        back = s[i].size() - 1 - s[acam.id1[pos[s[i].size() - 1]]].size()  + 1;
        for(int j = s[i].size() - 2;j >= 0;j--){
            if(j - s[acam.id[pos[j]]].size() + 1 >= back || !acam.id[pos[j]]){
                continue;
            }
            mp[acam.id[pos[j]]]++;
            back = j - s[acam.id[pos[j]]].size() + 1;
        }
        for(pair<int,int> p : mp)
        {
            int cnt = acam.bit.query(acam.dfn[ep[p.first]] + acam.siz[ep[p.first]] - 1) - acam.bit.query(acam.dfn[ep[p.first]] - 1);
            if(cnt == p.second){
                ans += 1;
            }
        }
        for(int j = 0;j < s[i].size();j++){
            acam.bit.update(acam.dfn[pos[j]],-1);
        }
    }
    cout<<ans<<'\n';
}